package object03;
/*
* 所有类都直接或间接的继承Object类
* */
public class Person {
    private String name;

    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    /*
    * object类中的toString方法默认返回的是内存地址的哈希值
    * 对于实际业务来说没有太大用处
    * 所以一般子类中都会重写此方法
    * */

/*    @Override
    public String toString(){
        return "姓名:" + name + "年龄" + age;
    }*/

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
